<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('列表')"/>
    <script th:src="@{/static/admin/js/pdf.js}"></script>
    <script th:src="@{/static/admin/js/pdf.worker.js}"></script>
</head>
<style>
    .layui-tab-title {
        /*background-color: #009688;*/
        background-color: #36b368;
        color: #F5F5F5;
        border-bottom: 2px solid #CCCCCC;
    }

    .layui-this {
        background-color: #F5F5F5;
    }

    .btn-dis {
        color: #CCCCCC !important;
    }

    .layui-tab-item {
        background-color: #F5F5F5;
        border: 1px solid #CCCCCC;
    }
    .layui-table th {
        text-align: center !important;
    }
    .layui-table-cell {
        padding: 0 5px;
        height: auto !important;
        overflow: visible;
        text-overflow: inherit;
        white-space: normal;
        word-break: break-all;
        line-height: 26px !important;
    }
    .layui-form-radio *{
        margin-right: 10px !important;
        margin-left: 5px !important;
    }
    .layui-table td{
        font-size: 13px !important;
    }

</style>
<body>
<div class="layui-card">
    <div class="layui-card-body">
        <button class="pear-btn pear-btn-md pear-btn-danger" lay-submit
                lay-filter="monthtask-submit">
            <!--            <i class="layui-icon layui-icon-upload-circle"></i>-->
            提 报
        </button>
        <button class="pear-btn pear-btn-md pear-btn-warming" lay-submit
                lay-filter="monthtask-selfscore">
            <!--            <i class="layui-icon layui-icon-engine"></i>-->
            查看自评分
        </button>
        <button class="pear-btn pear-btn-md pear-btn-warming" lay-submit
                lay-filter="monthtask-deduct">
            <!--            <i class="layui-icon layui-icon-engine"></i>-->
            查看扣分项
        </button>
    </div>
</div>
<div class="layui-tab layui-tab-brief" lay-filter="test-hash">
    <ul class="layui-tab-title" id="layui-tab-title">
    </ul>
    <div class="layui-tab-content" id="layui-tab-content">
        <!--        <div class="layui-tab-item layui-show">内容-1</div>-->
        <!--        <div class="layui-tab-item ">内容-2</div>-->
        <!--        <div class="layui-tab-item ">内容-3</div>-->
    </div>
</div>
<th:block th:include="include :: footer"/>

<!--必备条件表格&#45;&#45;自评价列单选-->
<script type="text/html" id="stateBar">
    <input type="radio" name="state{{d.id}}" value="{{d.id+'^^^'+d.typeSelf+'^^^1'}}" title="合格"
           lay-filter="lockDemo"
           {{ d.typeSelf== 1 ? 'checked' : '' }}>&nbsp;
    <input type="radio" name="state{{d.id}}" value="{{d.id+'^^^'+d.typeSelf+'^^^0'}}" title="不合格"
           lay-filter="lockDemo"
           {{ d.typeSelf== 0 ? 'checked' : '' }}>&nbsp;
</script>
<!--除”必备条件“外，其他表格”评价方式及材料“显示事件-->
<script type="text/html" id="content-event">
    {{#  if(d.type != 3){ }}
    <!--    <button class="pear-btn pear-btn-warming pear-btn-sm"-->
    <!--            lay-event="" title="填报帮助文档" onclick="viewrule('{{d.content}}')"><i class="layui-icon layui-icon-search"></i>-->
    <!--    </button>-->
    <button class="pear-btn pear-btn-primary pear-btn-sm"
            lay-event="" title="评价方式" onclick="viewrule('{{d.content}}')"><i
            class="layui-icon layui-icon-search"></i>
        评价方式
    </button>

    {{#  if (d.ishasSupport == '0'){ }}
    <button class="pear-btn pear-btn-disabled pear-btn-sm btn-dis"
            lay-event="" title="支撑文件查阅" onclick="supportFileView('{{d.fkParentProjectId}}' ,'{{d.num}}')"><i
            class="layui-icon layui-icon-file-b" ></i>
        支撑文件
    </button>
    {{#  }else{ }}
    <button class="pear-btn pear-btn-primary pear-btn-sm"
            lay-event="" title="支撑文件查阅" onclick="supportFileView('{{d.fkParentProjectId}}' ,'{{d.num}}')"><i
            class="layui-icon layui-icon-file-b" ></i>
        支撑文件
    </button>
    {{#  } }}

    {{#  if (d.ishasTemp == '0'){ }}
    <button class="pear-btn pear-btn-disabled pear-btn-sm btn-dis"
            lay-event="" title="材料模版查阅" onclick="materialStencils('{{d.fkParentProjectId}}')"><i
            class="layui-icon layui-icon-template-1"></i>
        材料模版
    </button>
    {{#  }else{ }}
    <button class="pear-btn pear-btn-primary pear-btn-sm"
            lay-event="" title="材料模版查阅" onclick="materialStencils('{{d.fkParentProjectId}}')"><i
            class="layui-icon layui-icon-template-1"></i>
        材料模版
    </button>
    {{#  } }}

    {{#  if (d.ishasProof == '0'){ }}
    <button class="pear-btn pear-btn-disabled pear-btn-sm" id="proof{{d.id}}"
            lay-event="" title="佐证上传" onclick="uploadCorroboration('{{d.fkParentProjectId}}' ,'{{d.id}}')">
    <i class="layui-icon layui-icon-upload"></i>
        佐证上传
    </button>
    {{#  }else{ }}
    <button class="pear-btn pear-btn-warming pear-btn-sm" id="proof{{d.id}}"
            lay-event="" title="佐证上传" onclick="uploadCorroboration('{{d.fkParentProjectId}}' ,'{{d.id}}')">
        <i class="layui-icon layui-icon-upload"></i>
        佐证上传
    </button>
    {{#  } }}
    {{#  }else{ }}
    <span>{{d.content}}</span>
    {{#  } }}
</script>

<script id="taskFillingScore-bar3" type="text/html">
    {{#if(d.type == 3 ){ }}
    <!--    <img th:src="@{/static/admin/images/img/carryOut.png}" class="layui-nav-img">-->
    {{# }else if (d.selfValue == '' || d.selfValue == null ){ }}
    <img th:src="@{/static/admin/images/img/notCarryOut.png}" class="layui-nav-img" id="{{'dataId'+d.id}}">
    {{# }else{ }}
    <img th:src="@{/static/admin/images/img/carryOut.png}" class="layui-nav-img" id="{{'dataId'+d.id}}">
    {{# } }}
</script>

<script th:inline="javascript" type="text/javascript">
    var tabTitleList = [[${tabTitleList}]];
    var taskId = [[${taskId}]];
    var tabTiletHtml = "";
    var tabBodyHtml = ""

    for (var i = 0; i < tabTitleList.length; i++) {
        tabTiletHtml += '<li className="layui-this" lay-id=' + tabTitleList[i].id + '>' + tabTitleList[i].content + '</li>'
        tabBodyHtml += '<div class="layui-tab-item" id="tab' + i + '">' + '<table id="tab' + i + '-table" class="layui-tab-table "tab' + i + '-table"></table>' + '</div>'
    }

    $('#layui-tab-title').html(tabTiletHtml);
    $('#layui-tab-content').html(tabBodyHtml);

    var MODULE_PATH = rootPath + "/MonthSupplytaskController/";
    var MODULE_PATH_NEC = rootPath + "/MonthNecessaryController/";
    var MODULE_PATH_DTL = rootPath + "/MonthSupplytaskDtlController/";
    var MODULE_PATH_FILE = rootPath + "/InfoFileController/";

    layui.use(['table', 'form', 'jquery', 'element', 'laydate', 'dtree'], function () {

        var $ = layui.jquery;
        var table = layui.table;
        var form = layui.form;

        $('#tab0').attr('class', "layui-tab-item layui-show");
        $("ul li:first").attr('class', "layui-this");

        // 根据返回数据中某个字段来判断开启该行的编辑
        var editable = function (d) {
            if (d.editable) return 'radio'; // 这里假设以 editable 字段为判断依据
        };
        var cols0 = [
            [
                // {type: 'checkbox'},
                {title: '项目编号', field: 'num', align: 'center', width: 100,},
                {title: '一级项目', field: 'firstProject', align: 'center', width: 150,},
                {title: '二级项目', field: 'secondProject', align: 'left', width: 420,},
                {title: '检查方式', field: 'testMode', align: 'left', width: 420,},
                {
                    title: '评价周期',
                    field: 'evaluationPeriod',
                    align: 'center',
                    width: 150,
                    templet: function (d) {
                        if (d.evaluationPeriod === '0') {
                            return '月度';
                        } else if (d.evaluationPeriod === '1') {
                            return '季度';
                        } else if (d.evaluationPeriod === '2') {
                            return '半年';
                        } else if (d.evaluationPeriod === '3') {
                            return '年初';
                        } else if (d.evaluationPeriod === '4') {
                            return '年末';
                        } else {
                            return '';
                        }
                    }
                },
                {title: '责任部门', field: 'resDeptName', align: 'center'},
                {field: 'typeSelf', title: '自评价', align: 'center', templet: '#stateBar'},
            ]
        ]

        var cols1 = [
            [
                {title: '填报状态', toolbar: '#taskFillingScore-bar3', align: 'center', width: 100},
                {title: '指标编号', field: 'num', align: 'center', width: 100},
                {
                    title: '指标名称', field: 'name', align: 'center', width: 500, templet: function (d) {
                        if (d.type == 3) {
                            return '<div style="text-align:center">' + d.name + '</div>'
                        } else {
                            return '<div style="text-align:left">' + d.name + '</div>'
                        }
                    }
                },
                {
                    title: '工作要求及完成情况',
                    field: 'selfValue',
                    align: 'center',
                    width: 320,
                    templet: function (d) {
                        if (d.type === '3') {
                            return '<div style="text-align:left"><span >' + d.selfValue + '</span></div>';
                        } else {
                            var helpicon = ''
                            if (d.ishasStep === '1') {
                                helpicon = '<button class="pear-btn pear-btn pear-btn-sm"\n' +
                                    '            lay-event="" title="填报帮助文档" onclick="viewhelp(\'' + d.num + '\')"><i class="layui-icon layui-icon-search"></i>\n' +
                                    '    </button>'
                            }

                            if (d.tactics === '1' || d.tactics === '3') {
                                var selfValue = d.selfValue == null ? "" : d.selfValue
                                if (d.isauto == 1) {
                                    return '<div class="layui-input-block" style="text-align:left">' +
                                        '<input type="text" readonly class="layui-input tianbao" style="width: 145px;text-align:center;display: inline-block;"  id = "' + d.id + '" value="' + selfValue + '"  data-old = "' + d.selfValue + '" data-num = "' + d.num + '" data-unit = "' + d.measuringUnit + '">'
                                        + '<span>' + d.measuringUnit + '</span>' + helpicon + '</div>'
                                } else {
                                    return '<div class="layui-input-block" style="text-align:left">' +
                                        '<input type="text" class="layui-input tianbao" style="width: 145px;text-align:center;display: inline-block;" id = "' + d.id + '" value="' + selfValue + '" onmouseout="onmouseouts(this)" ' +
                                        'data-old = "' + d.selfValue + '" data-num = "' + d.num + '" data-tab = "' + d.tab + '" data-unit = "' + d.measuringUnit + '">'
                                        + '<span>' + d.measuringUnit + '</span>' + helpicon + '</div>'
                                }
                            } else if (d.tactics === '2') {
                                if (d.isauto === 1) {
                                    if (d.selfValue === "1") {
                                        return '<div class="layui-form layui-input-block" style="text-align:left;">' +
                                            '<input type="radio" style="margin-right: 5px;"  disabled="disabled" checked name="radio' + d.id + '" value="' + d.id + '^^^' + d.selfValue + '^^^1^^^' + d.num + '"  title="是" lay-filter="selfValueDemo">' +
                                            '<input type="radio" disabled="disabled" name="radio' + d.id + '" value="' + d.id + '^^^' + d.selfValue + '^^^0^^^' + d.num + '" title="否" lay-filter="selfValueDemo">' + helpicon + '</div>';
                                    } else {
                                        return '<div class="layui-form layui-input-block" style="text-align:left;">' +
                                            '<input type="radio"  style="margin-right: 5px;" disabled="disabled" name="radio' + d.id + '" value="' + d.id + '^^^' + d.selfValue + '^^^1^^^' + d.num + '" title="是" lay-filter="selfValueDemo">' +
                                            '<input type="radio" disabled="disabled" checked name="radio' + d.id + '" value="' + d.id + '^^^' + d.selfValue + '^^^0^^^' + d.num + '" title="否" lay-filter="selfValueDemo">' + helpicon + '</div>';
                                    }
                                } else {
                                    if (d.selfValue === "1") {
                                        return '<div class="layui-form layui-input-block" style="text-align:left;">' +
                                            '<input type="radio"  class="tianbao" style="margin-right: 5px;" name="radio' + d.id + '" value="' + d.id + '^^^' + d.selfValue + '^^^1^^^' + d.num + '" title="是" lay-filter="selfValueDemo" checked>' +
                                            '<input type="radio" name="radio' + d.id + '" value="' + d.id + '^^^' + d.selfValue + '^^^0^^^' + d.num + '" title="否" lay-filter="selfValueDemo">' + helpicon + '</div>';
                                    } else if (d.selfValue === "0") {
                                        return '<div class="layui-form layui-input-block" style="text-align:left; ">' +
                                            '<input type="radio"  style="margin-right: 5px;" name="radio' + d.id + '" value="' + d.id + '^^^' + d.selfValue + '^^^1^^^' + d.num + '" title="是" lay-filter="selfValueDemo" >' +
                                            '<input type="radio" name="radio' + d.id + '" value="' + d.id + '^^^' + d.selfValue + '^^^0^^^' + d.num + '" title="否" lay-filter="selfValueDemo" checked>' + helpicon + '</div>';
                                    } else {
                                        return '<div class="layui-form layui-input-block" style="text-align:left;">' +
                                            '<input type="radio"  style="margin-right: 5px;" name="radio' + d.id + '" value="' + d.id + '^^^' + d.selfValue + '^^^1^^^' + d.num + '" title="是" lay-filter="selfValueDemo" >' +
                                            '<input type="radio" name="radio' + d.id + '" value="' + d.id + '^^^' + d.selfValue + '^^^0^^^' + d.num + '" title="否" lay-filter="selfValueDemo">' + helpicon + '</div>';
                                    }
                                }
                            } else {
                                return '';
                            }
                        }
                    }
                },
                {title: '责任部门', field: 'deptName', width: '10%',align: 'center'},
                // {
                //     title: '评价周期', field: 'evaluationPeriod', width: '10%', align: 'center', templet: function (d) {
                //         if (d.evaluationPeriod === '0') {
                //             return '月度';
                //         } else if (d.evaluationPeriod === '1') {
                //             return '季度';
                //         } else if (d.evaluationPeriod === '2') {
                //             return '半年';
                //         } else if (d.evaluationPeriod === '3') {
                //             return '年初';
                //         } else if (d.evaluationPeriod === '4') {
                //             return '年末';
                //         } else {
                //             return '';
                //         }
                //     }
                // },
                // {title: '评价方式及材料', field: 'fkParentProjectId', toolbar: '#button-bar', align: 'center',merge: true},
                {
                    title: '评价方式及材料',
                    field: 'fkParentProjectId',
                    align: 'center',
                    // width: 360,
                    templet: '#content-event',
                    merge: true
                },
                // {title: '项目分值',field: 'score', align: 'center', merge: true},
                // {title: '自评分', field: 'proscore', align: 'center', merge: true},
                // {title: '操作', toolbar: '#infoProject-bar', align: 'center'}
            ]
        ]


        //table表单列表
        table.render({
            elem: '#tab0-table',
            url: MODULE_PATH_NEC + 'list2/' + [[${taskId}]],
            page: false,
            method: 'get',
            cols: cols0,
            skin: 'line',
            id: 'tab0-table',
            scrollPos: 'fixed',
            loading: false,
            done: function (res) {
                res.data.forEach(function (item, index) {
                    if (item.type == 3) {
                        var tr = $(".layui-table").find("tbody tr[data-index='" + index + "']");
                        tr.css("background-color", "rgb( 0 , 176 , 80 )");
                        tr.find(".layui-table-cell").css("color", "#ffffff");
                    }
                });
            }
        });
        var table_data = new Array();
        for (var j = 1; j < tabTitleList.length; j++) {
            //table表单列表
            table.render({
                elem: '#tab' + j + '-table',
                url: MODULE_PATH_DTL + 'list2/' + [[${taskId}]] + '/' + j,
                page: false,
                method: 'get',
                cols: cols1,
                skin: 'line',
                id: 'tab' + j + '-table',
                scrollPos: 'fixed',
                loading: false,
                done: function (res) {
                    var that = this.elem.next();
                    table_data = res.data;
                    for (var i = 0; i < res.data.length; i++) {
                        if (res.data[i].type == 3) {
                            var index = res.data[i]['LAY_TABLE_INDEX'];
                            var tr = that.find(".layui-table tr[data-index='" + index + "']");
                            // tr.css("cssText", "height:100px !important");
                            tr.css("background", "rgba(192,252,179,0.35)");
                            tr.find("a[lay-event='put']").prop('disabled', true);
                            tr.find("a[lay-event='put']").removeClass("layui-btn-normal").addClass("layui-btn-disabled");
                        }
                    }
                    merge(this);
                }

            });
        }
        /**
         * 必备条件单选更新
         */
        form.on('radio(lockDemo)', function (data) {
            // //id
            // console.log(data.value.split('^^^')[0])
            // //是否--回显
            // console.log(data.value.split('^^^')[1])
            // //是否---前端值
            // console.log(data.value.split('^^^')[2])

            var id = data.value.split('^^^')[0];
            var typeSelfValue = data.value.split('^^^')[2];
            $.ajax({
                url: MODULE_PATH_NEC + '/updateSelf',
                data: JSON.stringify({"id": id, "typeSelf": typeSelfValue}),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function (result) {
                    if (result.code == 200) {
                        // layui.table.reload("tab0-table");
                    } else {
                        layer.msg(result.msg, {icon: 2, time: 1000});
                    }
                }
            })
        })

        //支撑文件-d为id
        window.supportFileView = function (d,num) {
            console.log(d)
            var index = layer.open({
                type: 2,
                title: '项目---'+num+'----支撑文件查看',
                shade: 0.1,
                area: ['1300px', '650px'],
                maxmin: true,//该参数值对type:1和type:2有效。默认不显示最大小化按钮。需要显示配置maxmin: true即可
                // content: MODULE_PATH_FILE + 'upload/' + d +'/1'
                content: MODULE_PATH_FILE + 'fileview/' + d + '/1/' + taskId
            });
            // layer.full(index)
        }
        //材料模版 -d为id
        window.materialStencils = function (d) {
            //下载连接
            var index = layer.open({
                type: 2,
                title: '模板资料下载',
                shade: 0.1,
                area: ['1300px', '650px'],
                content: MODULE_PATH_FILE + 'templatedownload/' + d + '/2/' + taskId
            });
        }

        //上传佐证 -d为id
        window.uploadCorroboration = function (parentid,id) {
            var index = layer.open({
                type: 2,
                title: parentid+'----佐证上传与历史佐证查看',
                shade: 0.1,
                area: ['1400px', '700px'],
                maxmin: true,
                content: MODULE_PATH_FILE + 'proofupload/' + parentid + '/3/' + taskId,
                end:function (){
                    $.ajax({
                        url: MODULE_PATH_FILE + '/proofexist',
                        data: JSON.stringify({"fkRecord": parentid,"fkTaskId":taskId}),
                        dataType: 'json',
                        contentType: 'application/json',
                        type: 'post',
                        success: function (result) {
                            console.log(result)
                            if (result.code == 200) {
                                if (result.data == 1){
                                    $('#proof' + id + '').attr('class', 'pear-btn pear-btn-warming pear-btn-sm');
                                }else {
                                    $('#proof' + id + '').attr('class', 'pear-btn pear-btn-disabled pear-btn-sm');
                                }
                            } else {
                                layer.msg(result.msg, {icon: 2, time: 1000});
                            }
                        }
                    })
                }
            });
            // layer.full(index)
        }

        //查看评分细则
        window.viewrule = function (d) {
            layer.open({
                type: 1,
                title: '评价方式',
                area: ['500px', '500px'],
                // content: '<div><textarea name="description">'+d+'</textarea></div>'
                content: d
            });
        }

        //查看辅助文档
        window.viewhelp = function (d) {
            var index = layer.open({
                type: 2,
                title: d + '填报辅助说明',
                shade: 0.1,
                // area: ['650px', '650px'],
                content: MODULE_PATH + 'viewhelp/' + d
            });
            layer.full(index)
        }

        //除必备条件其他所有表格--单选监听事件
        form.on('radio(selfValueDemo)', function (data) {
            console.log(data)
            // //id
            // console.log(data.value.split('^^^')[0])
            // //是否--回显
            // console.log(data.value.split('^^^')[1])
            // //是否---前端值
            // console.log(data.value.split('^^^')[2])
            var id = data.value.split('^^^')[0];
            var typeSelfValue = data.value.split('^^^')[2];
            var num = data.value.split('^^^')[3];
            var tab = num.split(".")[0]
            $.ajax({
                url: MODULE_PATH_DTL + '/updateSelf',
                data: JSON.stringify({"id": id, "selfValue": typeSelfValue}),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function (result) {
                    if (result.code == 200) {
                        // var tabletab = 'tab' + tab + '-table'
                        // layui.table.reloadData(tabletab, {
                        //     scrollPos: 'fixed',
                        //     loading: false,
                        // });
                        if (typeSelfValue!=null||typeSelfValue!=""||typeSelfValue.trim.length()!=0){
                            $('#dataId' + id + '').attr('src', '/static/admin/images/img/carryOut.png');
                        }else{
                            $('#dataId' + id + '').attr('src', '/static/admin/images/img/notCarryOut.png');
                        }

                    } else {
                        layer.msg(result.msg, {icon: 2, time: 1000});
                    }
                }
            })
        })

        //input监听事件----重要
        window.onmouseouts = function (e) {
            // //新输入的内容
            // console.log(e.value)
            //
            // //id
            // console.log(e.id)
            // //旧的内容
            // console.log($('#' + e.id).attr('data-old'))
            var id = e.id;
            $('#'+id).blur();
            var typeSelfValue = e.value;
            var num = $('#' + e.id).attr('data-num')
            var tab = num.split(".")[0]
            var old = $('#' + e.id).attr('data-old')
            var unit = $('#' + e.id).attr('data-unit')
            var tabletab = 'tab' + tab + '-table'

            var updateflag = true;

            //数据规范
            //百分数0~100待优化

            console.log("旧:"+old)

            if (typeSelfValue == null ||typeSelfValue== "null"|| typeSelfValue === "" || typeSelfValue.length === 0) {
                if (!(old == null || old === "null" || old === ""|| old.length === 0)) {
                    updateflag = true
                } else {
                    console.log("new 空 old 空")
                    updateflag = false
                }
            } else {

                if (typeSelfValue === old) {
                    console.log("值相同，不刷新")
                    updateflag = false
                }else{
                    var reg = /^[0-9]+(\.[0-9]{0,4})?$/;
                    var reg1 = /^\d+$/;
                    if (reg.test(typeSelfValue)) { //正则匹配通过
                        if (unit === "%") {
                            if (!(typeSelfValue >= 0 && typeSelfValue <= 100)) {
                                layer.msg("指标编号为" + num + "的数据行百分数填写不规范", {icon: 2, time: 2000});
                                layui.table.reloadData(tabletab, {
                                    scrollPos: 'fixed',
                                    loading: false,
                                });
                                updateflag = false;
                            }
                        } else {
                            if (!reg1.test(typeSelfValue)) {
                                layer.msg("指标编号为" + num + "的数据行数据填写不规范，请填写正整数或0", {
                                    icon: 2,
                                    time: 2000
                                });
                                layui.table.reloadData(tabletab, {
                                    scrollPos: 'fixed',
                                    loading: false,
                                });
                                updateflag = false;
                            }
                        }
                    } else {
                        updateflag = false;
                        layer.msg("指标编号为" + num + "的数据行数据填写不规范", {icon: 2, time: 2000});
                        layui.table.reloadData(tabletab, {
                            scrollPos: 'fixed',
                            loading: false,
                        });
                    }
                }
            }

            if (updateflag) {
                console.log("需要更新")
                // console.log($(".tabletab").attr('id'))
                // $(".tianbao").attr('disabled',true);
                $.ajax({
                    url: MODULE_PATH_DTL + '/updateSelf',
                    data: JSON.stringify({"id": id, "selfValue": typeSelfValue}),
                    dataType: 'json',
                    contentType: 'application/json',
                    type: 'post',
                    async:false,
                    success: function (result) {
                        if (result.code == 200) {
                            console.log("数值返回了")
                            // layui.table.reloadData(tabletab, {
                            //     scrollPos: 'fixed',
                            //     loading: false
                            // });
                            // $(".tianbao").attr('disabled',false);
                            console.log("输入值最新:"+typeSelfValue)
                            $('#'+id).attr("data-old",typeSelfValue)
                            if (typeSelfValue == null || typeSelfValue === "" || typeSelfValue.length === 0){
                                $('#dataId' + id + '').attr('src', '/static/admin/images/img/notCarryOut.png');
                            }else{
                                $('#dataId' + id + '').attr('src', '/static/admin/images/img/carryOut.png');
                            }
                        } else {
                            layer.msg(result.msg, {icon: 2, time: 1000});
                            // $(".tianbao").attr('disabled',false);
                        }
                    }
                })
            }
        }

        var element = layui.element;

        // tab 切换事件
        element.on('tab(test-hash)', function(data){
            console.log(this); // 当前 tab 标题所在的原始 DOM 元素
            console.log(data.index); // 得到当前 tab 项的所在下标
            console.log(data.elem); // 得到当前的 tab 容器
            $(".tianbao").attr('disabled',false);
        });

        //提报按钮绑定
        form.on('submit(monthtask-submit)', function (data) {
            $.ajax({
                url: MODULE_PATH + '/fillCommit',
                data: JSON.stringify({"id": taskId}),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function (result) {
                    if (result.code == 200) {
                        layer.msg("提报成功,请关注审核进程", {icon: 1, time: 3000}, function () {
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.location.reload(); //刷新父页面
                            //parent.layer.close(index);
                        });
                    } else {
                        layer.msg(result.msg, {icon: 2, time: 3000});
                    }
                }
            })
        });

        //查看自评分按钮绑定
        form.on('submit(monthtask-selfscore)', function (data) {
            var index = layer.open({
                type: 2,
                title: '自评价实时得分计算',
                shade: 0.1,
                area: ['1600px', '260px'],
                content: MODULE_PATH + 'findSelfScore/' + taskId
            });
            // layer.full(index)
        });

        //查看扣分项按钮绑定
        form.on('submit(monthtask-deduct)', function (data) {
            var index = layer.open({
                type: 2,
                title: '自评价实时扣分项',
                shade: 0.1,
                area: ['90%', '70%'],
                content: MODULE_PATH + 'findDeduct/' + taskId
            });
            // layer.full(index)
        });
    })


    function merge(myTable, skipFlag = true) {
        var tableBox = $(myTable.elem).next().children('.layui-table-box'),
            $main = $(tableBox.children('.layui-table-body').children('table').children('tbody').children('tr').toArray().reverse()),
            $fixLeft = $(tableBox.children('.layui-table-fixed-l').children('.layui-table-body').children('table').children('tbody').children('tr').toArray().reverse()),
            $fixRight = $(tableBox.children('.layui-table-fixed-r').children('.layui-table-body').children('table').children('tbody').children('tr').toArray().reverse()),
            cols = myTable.cols[0], mergeRecord = {};

        for (var i = 0; i < cols.length; i++) {
            var item3 = cols[i], field = item3.field;
            if (item3.merge) {
                var mergeField = [field];
                if (item3.merge !== true) {
                    if (typeof item3.merge == 'string') {
                        mergeField = [item3.merge]
                    } else {
                        mergeField = item3.merge
                    }
                }
                mergeRecord[i] = {mergeField: mergeField, rowspan: 1}
            }
        }

        $main.each(function (i) {
            for (var _recordIndex in mergeRecord) {
                var _mergeRecord = mergeRecord[_recordIndex];
                //检查前一个字段
                var _beforeMergeRecord = mergeRecord[_recordIndex - 1];
                //
                if (i === $main.length - 1 || (skipFlag && _beforeMergeRecord && _beforeMergeRecord.rowspan === 1) || isMaster(i, _mergeRecord)) {
                    $(this).children('[data-key$="-' + _recordIndex + '"]').attr('rowspan', _mergeRecord.rowspan);
                    $fixLeft.eq(i).children('[data-key$="-' + _recordIndex + '"]').attr('rowspan', _mergeRecord.rowspan);
                    $fixRight.eq(i).children('[data-key$="-' + _recordIndex + '"]').attr('rowspan', _mergeRecord.rowspan);
                    _mergeRecord.rowspan = 1;
                } else {
                    $(this).children('[data-key$="-' + _recordIndex + '"]').remove();
                    $fixLeft.eq(i).children('[data-key$="-' + _recordIndex + '"]').remove();
                    $fixRight.eq(i).children('[data-key$="-' + _recordIndex + '"]').remove();
                    _mergeRecord.rowspan += 1;
                }
            }
        })

        function isMaster(index, _mergeRecord) {
            var mergeField = _mergeRecord.mergeField;
            var dataLength = layui.table.cache[myTable.id].length;
            for (var i = 0; i < mergeField.length; i++) {

                if (layui.table.cache[myTable.id][dataLength - 2 - index][mergeField[i]]
                    !== layui.table.cache[myTable.id][dataLength - 1 - index][mergeField[i]]) {
                    return true;
                }
            }
            return false;
        }
    }


</script>
</body>
</html>